package com.sfx.concurrent.demo.concurrent.MultipleLock;

import lombok.extern.slf4j.Slf4j;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: sfx
 * Date: 2023-01-07
 * Time: 16:23
 */

@Slf4j(topic = "c.BigRoom")
public class BigRoom {
    private static final Object studyingRoom = new Object();
    private static final Object sleepingRoom = new Object();

    public void studying() {
        synchronized (studyingRoom) {
            log.debug("study2000ms....");
            try {
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
    public void sleeping() {
        synchronized (sleepingRoom) {
            log.debug("sleeping1000ms....");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
class TestMain {
    public static void main(String[] args) {
        BigRoom bigRoom = new BigRoom();
        new Thread(()->{
            bigRoom.studying();
        },"小南").start();
        new Thread(()->{
            bigRoom.sleeping();
        },"小女").start();
    }
}

